<?php
global $_POST;
require_once('./roots.php');
require_once('./classes/rbac.php');
require($root_path.'include/inc_environment_global.php');


$rbac=new rbac();

$gui=$rbac->Buscar_rol_usuario($_POST['name'],NULL,$_SESSION['sess_login_username']);
//var_dump($gui);

$rol=$_POST['name'];
foreach ($gui as $key => $value) {

//echo "valor:".$value["id_user"]." <br />\n";
$aux=$rbac->Revocar_rol_usuario($rol,$value["id_user"],$_SESSION['sess_login_username']);
}




$gui1=$rbac->Buscar_permiso($_POST['name'],NULL,NULL,$_SESSION['sess_login_username']);
//var_dump($gui);

$user=$_POST['login_id'];
foreach ($gui1 as $key => $value) {

//echo "rol:".$value["id_role"]."   recurso:".$value["id_resource"]."  permiso:".$value["action"]." <br />\n";
$aux1=$rbac->Revocar_permiso($value["id_role"],$value["id_resource"],$value["action"],$_SESSION['sess_login_username']);
}


$result=$rbac->Destruir_rol($_POST['name'], $_SESSION['sess_login_username']);

header("Location:$root_path/modules/rbac/RolListEliminar.php?result=".$result."&lang=".$lang);

?>
